// pages/procedure/procedure.js

const app = getApp()
let isIphoneX = app.globalData.isIphoneX;

import {
  ajax,
  src,
  util
} from "../../utils/util.js";
Page({

  /**
   * 页面的初始数据
   */
  data: {
    uqid: "",
    nonext:0,
    isshow:0,
    isselectnots:false,
    image:"",
    isiphonex: isIphoneX,
    did:""
  },

  /**
   * 生命周期函数--监听页面加载
   */
  selectnots:function(){
    this.setData({
      isselectnots:!this.data.isselectnots
    })

    if (this.data.isselectnots) {
      ajax("/api/user/prompt_edit", {
        data: {
          uqid: this.data.uqid,
          type:0
      },
        header: {
          'Accept': 'application/json', // 默认值
        },
        method: "PUT"
      }, res => {
        console.log(res);
        if (res.error == 0) {
        }
      })
    }else{
      ajax("/api/user/prompt_edit", {
        data: {
          uqid: this.data.uqid,
          type:1
        },
        header: {
          'Accept': 'application/json', // 默认值
        },
        method: "PUT"
      }, res => {
        console.log(res);
        if (res.error == 0) {
        }
      })
    }
  },

  getimg:function(){
    ajax("/api/user/helps", {
      data: {
        uqid: this.data.uqid,
      },
      header: {
        'Accept': 'application/json', // 默认值
      },
      method: 'GET'
    }, res => {
      console.log(res);

      if (res.error == 0) {
        this.setData({
          image: res.data.image
        })
      }
    })
  },

  // 点击我知道了
  toscan:function(e){
    
    var _this = this;

    wx.scanCode({
      success: (res) => {
        var result = res.result;
        _this.setData({
          did: result,
        })

        wx.navigateTo({
          url: '/pages/unlocking/unlocking?did=' + this.data.did,
        })
      }
    })


  },
  onLoad: function (options) {
    var nonext=options.nonext
    if(nonext){
      this.setData({
        nonext:nonext
      })
    }
    var uqid = wx.getStorageSync("uqid")
    this.setData({
      uqid: uqid
    })
    this.getimg()
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})